﻿
@model Tuple<
    deviceManage.Models.Device, List<deviceManage.Models.Depart>
>
@{
    Layout = null;
}

<div class="layui-form" lay-filter="form" style="padding: 20px 30px 0 0;">
    <input type="hidden" name="DeviceId" value="@Model.Item1.Id" />
    <div class="layui-form-item">
        <label class="layui-form-label">设备名称</label>
        <div class="layui-input-inline" style="width:400px;">
            <input type="text"    value="@Model.Item1.Name" readonly style="border:0"
                 autocomplete="off" class="layui-input" >
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">转出部门</label>
        <div class="layui-input-inline" style="width:150px;">
            <select name="DepartId" lay-filter="depart">
                <option></option>
                @foreach (var type in Model.Item2)
                {
                    <option value="@type.Id">@type.Name</option>
                }
            </select>
        </div>
        <div class="layui-input-inline">
            <input type="text" name="DepartName" id="DepartName" lay-verify="required" placeholder="请输入外借部门"
                   autocomplete="off" class="layui-input layui-form-danger" maxlength="100">
        </div>
    </div>
    
    <div class="layui-form-item">
        <label class="layui-form-label">转出日期</label>
        <div class="layui-input-inline">
            <input type="text" name="TransferDate" value="" lay-verify="required" readonly id="TransferDate"
                   placeholder="转出日期" autocomplete="off" class="layui-input date">
        </div>

    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">说明备注</label>
        <div class="layui-input-inline">
            <textarea name="Reason" class="layui-input" style="height:80px;width:400px;"></textarea>
        </div>
    </div>
    

    <div style="text-align:center;">
        <input type="button" lay-submit="" lay-filter="save" value="确认" class="layui-btn">
    </div>
</div>
<script type="text/javascript">
    form.render("", 'form');
    laydate.render({
        'elem': '#TransferDate'
    });
    //监听下拉
    form.on('select(depart)', function (data) {
        console.log(data);
        var text = $('dd[lay-value=' + data.value + ']').text();
        $('#DepartName').val(text);
    });

    //监听提交
    form.on('submit(save)', function (data) {
        var field = data.field; //获取提交的字段 
        //提交 Ajax 成功后，关闭当前弹层并重载表格
        $.post("/deviceChange/AddMoveOutLog", field, function (d) {
            layer.msg(d.msg);
            if (d.code == 1) {
                layer.close(winIndex); tableObj.reload();
            }
        });

    });
</script>